package com.xsoft.demo3;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private ImageView picture;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        picture = findViewById(R.id.picture);
        findViewById(R.id.center_btn).setOnClickListener(this);
        findViewById(R.id.center_crop_btn).setOnClickListener(this);
        findViewById(R.id.center_inside_btn).setOnClickListener(this);
        findViewById(R.id.fit_center_btn).setOnClickListener(this);
        findViewById(R.id.fit_xy_btn).setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.center_btn:
                picture.setScaleType(ImageView.ScaleType.CENTER);
                break;
            case R.id.center_crop_btn:
                picture.setScaleType(ImageView.ScaleType.CENTER_CROP);
                break;
            case R.id.center_inside_btn:
                picture.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
                break;
            case R.id.fit_center_btn:
                picture.setScaleType(ImageView.ScaleType.FIT_CENTER);
                break;
            case R.id.fit_xy_btn:
                picture.setScaleType(ImageView.ScaleType.FIT_XY);
                break;
        }
    }
}